﻿using UnityEngine;

namespace GameLogic
{
    public class FightControlerWindows : FightControler
    {
        Vector2Int AimPos ;
        #region 生命周期回调
        public override void Awake()
        {
        }
        public override void Update()
        {
            Vector2Int moveDir = Vector2Int.zero;
            if (Input.GetKey(KeyCode.A))
                moveDir.x = -255;
            else if (Input.GetKey(KeyCode.D))
                moveDir.x = 255;
            else
                moveDir.x = 0;
            if (Input.GetKey(KeyCode.W))
                moveDir.y = 255;
            else if (Input.GetKey(KeyCode.S))
                moveDir.y = -255;
            else
                moveDir.y = 0;

            var targetPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            var aimPos = new Vector2Int((int)(targetPosition.x * 1000), (int)(targetPosition.y * 1000));
            if (aimPos != AimPos)
            {
                m_OnAimPositionCallback.Invoke(aimPos);
            }

            if (Input.GetKey(KeyCode.LeftShift))
            {
                m_OnFocusPositionCallback.Invoke(aimPos); ;
            }
            if (m_TargetMoveVec != moveDir)
            {
                m_TargetMoveVec = moveDir;
                if (m_OnMoveDirChangedCallback != null)
                    m_OnMoveDirChangedCallback.Invoke(m_TargetMoveVec);
            }
            if(m_Fire != Input.GetMouseButton(0))
            {
                m_Fire = Input.GetMouseButton(0);
                m_OnFireChangedCallback.Invoke(m_Fire);
            }
        }
        #endregion
        #region 开放接口
        public override void OnStartFight()
        {
        }
        #endregion

        #region 私有接口
        #endregion

    }
}
